import java.util.Scanner;

public class Demo4 {

private static Object locker=new Object();

public static void main(String[] args) {
     Thread t1=new Thread(()->{
    synchronized (locker){
        System.out.println(" t1 wait 之前");
        try {
            locker.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("t1 wait 之后");
    }
});

        Thread t2=new Thread(()->{
            synchronized (locker){
                System.out.println(" t2 wait 之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("t2 wait 之后");
            }
        });


        Thread t3=new Thread(()->{
            synchronized (locker){
                System.out.println(" t3 wait 之前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("t3 wait 之后");
            }
        });
        Thread t4=new Thread(()->{
            Scanner scanner=new Scanner(System.in);
            scanner.next();
            System.out.println("t4 notify之前");
            synchronized (locker){
                //locker.notifyAll();
                locker.notify();
                locker.notify();
                locker.notify();
                locker.notify();

                locker.notify();
                locker.notify();
                locker.notify();
                locker.notify();
                locker.notify();
                locker.notify();
                locker.notify();
                locker.notify();
                locker.notify();
                locker.notify();
                locker.notify();
            }
        });
        t1.start();
        t2.start();
        t3.start();
        t4.start();
    }
}
